-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[clang][bytecode] Fail on reads from constexpr-unknown pointers #164996
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
If they aren't const. Fixes llvm#164985
|
@llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) ChangesIf they aren't const. Fixes #164985 Full diff: https://github.com/llvm/llvm-project/pull/164996.diff 2 Files Affected:
diff --git a/clang/lib/AST/ByteCode/Interp.cpp b/clang/lib/AST/ByteCode/Interp.cpp
index a72282caf5e73..5d89f32d6bdc2 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -832,6 +832,8 @@ bool CheckLoad(InterpState &S, CodePtr OpPC, const Pointer &Ptr,
return false;
if (!CheckVolatile(S, OpPC, Ptr, AK))
return false;
+ if (!Ptr.isConst() && !S.inConstantContext() && isConstexprUnknown(Ptr))
+ return false;
return true;
}
diff --git a/clang/test/AST/ByteCode/codegen-cxx20.cpp b/clang/test/AST/ByteCode/codegen-cxx20.cpp
new file mode 100644
index 0000000000000..c1ef629da1e88
--- /dev/null
+++ b/clang/test/AST/ByteCode/codegen-cxx20.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -triple x86_64-linux -emit-llvm -o - %s -fcxx-exceptions | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-linux -emit-llvm -o - %s -fcxx-exceptions -fexperimental-new-constant-interpreter | FileCheck %s
+
+
+/// The read from a used to succeed, causing the entire if statement to vanish.
+extern void e();
+int somefunc() {
+ auto foo = [a = false]() mutable {
+ if (a)
+ e();
+ };
+ foo();
+}
+
+// CHECK: call void @_Z1ev()
|
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/65/builds/24562 Here is the relevant piece of the build log for the reference |
…#164996) If they aren't const. Fixes llvm#164985
…#164996) If they aren't const. Fixes llvm#164985
…#164996) If they aren't const. Fixes llvm#164985
If they aren't const.
Fixes #164985